package pl.ydp.components.mathcell.mathrecognizer.engine.database.modelsets.math_basic
{
	import flash.net.getClassByAlias;
	
	import pl.ydp.components.mathcell.mathrecognizer.characters.Character;
	import pl.ydp.components.mathcell.mathrecognizer.engine.database.modelsets.math_basic.characters.MB_ch_0;
	import pl.ydp.components.mathcell.mathrecognizer.engine.database.modelsets.math_basic.characters.MB_ch_1;
	import pl.ydp.components.mathcell.mathrecognizer.engine.database.modelsets.math_basic.characters.MB_ch_2;
	import pl.ydp.components.mathcell.mathrecognizer.engine.database.modelsets.math_basic.characters.MB_ch_3;
	import pl.ydp.components.mathcell.mathrecognizer.engine.database.modelsets.math_basic.characters.MB_ch_4;
	import pl.ydp.components.mathcell.mathrecognizer.engine.database.modelsets.math_basic.characters.MB_ch_5;
	import pl.ydp.components.mathcell.mathrecognizer.engine.database.modelsets.math_basic.characters.MB_ch_6;
	import pl.ydp.components.mathcell.mathrecognizer.engine.database.modelsets.math_basic.characters.MB_ch_7;
	import pl.ydp.components.mathcell.mathrecognizer.engine.database.modelsets.math_basic.characters.MB_ch_8;
	import pl.ydp.components.mathcell.mathrecognizer.engine.database.modelsets.math_basic.characters.MB_ch_9;
	import pl.ydp.components.mathcell.mathrecognizer.engine.database.modelsets.math_basic.characters.MB_ch_apx;
	import pl.ydp.components.mathcell.mathrecognizer.engine.database.modelsets.math_basic.characters.MB_ch_brc;
	import pl.ydp.components.mathcell.mathrecognizer.engine.database.modelsets.math_basic.characters.MB_ch_bro;
	import pl.ydp.components.mathcell.mathrecognizer.engine.database.modelsets.math_basic.characters.MB_ch_cma;
	import pl.ydp.components.mathcell.mathrecognizer.engine.database.modelsets.math_basic.characters.MB_ch_div;
	import pl.ydp.components.mathcell.mathrecognizer.engine.database.modelsets.math_basic.characters.MB_ch_divg;
	import pl.ydp.components.mathcell.mathrecognizer.engine.database.modelsets.math_basic.characters.MB_ch_divs;
	import pl.ydp.components.mathcell.mathrecognizer.engine.database.modelsets.math_basic.characters.MB_ch_dot;
	import pl.ydp.components.mathcell.mathrecognizer.engine.database.modelsets.math_basic.characters.MB_ch_equ;
	import pl.ydp.components.mathcell.mathrecognizer.engine.database.modelsets.math_basic.characters.MB_ch_goe;
	import pl.ydp.components.mathcell.mathrecognizer.engine.database.modelsets.math_basic.characters.MB_ch_gre;
	import pl.ydp.components.mathcell.mathrecognizer.engine.database.modelsets.math_basic.characters.MB_ch_les;
	import pl.ydp.components.mathcell.mathrecognizer.engine.database.modelsets.math_basic.characters.MB_ch_loe;
	import pl.ydp.components.mathcell.mathrecognizer.engine.database.modelsets.math_basic.characters.MB_ch_min;
	import pl.ydp.components.mathcell.mathrecognizer.engine.database.modelsets.math_basic.characters.MB_ch_mul;
	import pl.ydp.components.mathcell.mathrecognizer.engine.database.modelsets.math_basic.characters.MB_ch_mula;
	import pl.ydp.components.mathcell.mathrecognizer.engine.database.modelsets.math_basic.characters.MB_ch_mulx;
	import pl.ydp.components.mathcell.mathrecognizer.engine.database.modelsets.math_basic.characters.MB_ch_neq;
	import pl.ydp.components.mathcell.mathrecognizer.engine.database.modelsets.math_basic.characters.MB_ch_pls;
	import pl.ydp.components.mathcell.mathrecognizer.model.ShapeModel;
	
	public class ModelSetMathBasic
	{
		private static var _additionalClasses:Array = [];
		
		public static function addModelsClasses( characters:Array ):void
		{
			var classes:Array = [];
			for each( var char:String  in characters ){
			
				var clazz:Class = getClassFromChar( char );
				if( clazz ){
					classes.push( clazz );
				}
			}
			_additionalClasses = _additionalClasses.concat( classes );
		}
		
		private static function getClassFromChar( char:String ):Class
		{
			var charCode:Number = char.charCodeAt();
			var clazz:Class = map[ charCode ] as Class;
			return clazz;
		}
		
		
		public static function getModels():Array{
			var models:Array = new Array();
			var sm:ShapeModel
			var source:Array;
			
			
			for each (sm in MB_ch_0.getModels()){
				models.push(sm);
			}
			for each (sm in MB_ch_1.getModels()){
				models.push(sm);
			}
			for each (sm in MB_ch_2.getModels()){
				models.push(sm);
			}
			for each (sm in MB_ch_3.getModels()){
				models.push(sm);
			}
			for each (sm in MB_ch_4.getModels()){
				models.push(sm);
			}
			for each (sm in MB_ch_5.getModels()){
				models.push(sm);
			}
			for each (sm in MB_ch_6.getModels()){
				models.push(sm);
			}
			for each (sm in MB_ch_7.getModels()){
				models.push(sm);
			}
			for each (sm in MB_ch_8.getModels()){
				models.push(sm);
			}
			for each (sm in MB_ch_9.getModels()){
				models.push(sm);
			}
			
			
			for each (sm in MB_ch_pls.getModels()){
				models.push(sm);
			}
			for each (sm in MB_ch_mul.getModels()){
				models.push(sm);
			}
			// synonimy znaków mnożenia i dzielenie zostały usunięte task#43387
			/*
			for each (sm in MB_ch_mula.getModels()){
				models.push(sm);
			}
			
			for each (sm in MB_ch_mulx.getModels()){
				models.push(sm);
			}
			*/
			for each (sm in MB_ch_div.getModels()){
				models.push(sm);
			}
			// synonimy znaków mnożenia i dzielenie zostały usunięte task#43387
			/*
			for each (sm in MB_ch_divg.getModels()){
				models.push(sm);
			}
			for each (sm in MB_ch_divs.getModels()){
				models.push(sm);
			}
			*/
			for each (sm in MB_ch_min.getModels()){
				models.push(sm);
			}
			
			
			for each (sm in MB_ch_apx.getModels()){
				models.push(sm);
			}
			
			for each (sm in MB_ch_equ.getModels()){
				models.push(sm);
			}
			
			for each (sm in MB_ch_dot.getModels()){
				models.push(sm);
			}
			
			for each (sm in MB_ch_cma.getModels()){
				models.push(sm);
			}
			
			for each (sm in MB_ch_bro.getModels()){
				models.push(sm);
			}
			
			for each (sm in MB_ch_brc.getModels()){
				models.push(sm);
			}
			
			for each (sm in MB_ch_neq.getModels()){
				models.push(sm);
			}
			
			for each (sm in MB_ch_les.getModels()){
				models.push(sm);
			}
			
			for each (sm in MB_ch_loe.getModels()){
				models.push(sm);
			}
			
			for each (sm in MB_ch_gre.getModels()){
				models.push(sm);
			}
			
			for each (sm in MB_ch_goe.getModels()){
				models.push(sm);
			}
			
			var addidionalModels:Array = getModelsFromAdditionalClasses();
			models = models.concat( addidionalModels );
			
			return models;
		}
		
		private static function getModelsFromAdditionalClasses():Array
		{
			var models:Array = [];
			
			for each( var clazz:Class in _additionalClasses ){
				var newModels:Array = clazz.getModels();
				models = models.concat( newModels );
			}
			return models;
		}
		
		
		private static function get map():Object
		{
			var mapOb:Object = {};
			
			// synonimy znaków mnożenia i dzielenie zostały usunięte task#43387
			mapOb[ Character.MULTIPLY_A ] = MB_ch_mula;
			mapOb[ Character.MULTIPLY_X ] = MB_ch_mulx;
			
			// synonimy znaków mnożenia i dzielenie zostały usunięte task#43387
			mapOb[ Character.DIVIDE_G ] = MB_ch_divg;
			mapOb[ Character.DIVIDE_S ] = MB_ch_divs;
			
			return mapOb;
		}
	}
}